home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / gs24src.zip / TRACEOP.PS < prev    next >
Text File  |  1992-02-08  |  1KB  |  43 lines

  1. % Trace individual operators or procedures.
  2. % <opname> traceop prints vmem usage
  3. % <opname> <numargs|preproc> prints arguments or runs proc before
  4. % <opname> <numargs|preproc> <numresults|postproc>
  5. %    also prints results or runs proc after
  6. % If traceflush is true, flush the output after each printout.
  7. /traceflush true def
  8.  
  9. % Define the default "before" action
  10. /tracebefore { vmstatus 3 traceprint pop pop pop } def
  11.  
  12. % Define the default "after" action
  13. /traceafter { } def
  14.  
  15. /traceprint
  16.  { dup type /integertype eq
  17.     { 1 sub -1 0 { ( ) print index ==only } for }
  18.     { exec }
  19.    ifelse
  20.  } bind def
  21. /traceend
  22.  { traceflush { flush } if
  23.  } bind def
  24. /traceop
  25.  { userdict begin
  26.    dup type /nametype eq { { tracebefore } } if
  27.    1 index type /nametype eq { { traceafter } } if
  28.    /.tpost exch def /.tpre exch def /.tname exch def
  29.    .tname where not { .tname {} def userdict } if /.tdict exch def
  30.    .tdict dup systemdict eq { pop userdict } if /.tddict exch def
  31.    [ .tname /=only cvx ( ) /print cvx
  32.      /.tpre load /traceprint cvx /traceend cvx
  33.      .tname load
  34.      dup xcheck
  35.       { dup type dup /arraytype eq exch /packedarraytype eq or
  36.          { /exec cvx
  37.      } if
  38.       } if
  39.      /.tpost load /traceprint cvx (\n) /print cvx /traceend cvx
  40.    ] cvx .tddict exch .tname exch put end
  41.  } bind def
  42. /bind { } def        % disable
  43.